/**
 * This is my code.
 *
 * $Id$
 */
package fi.jab.esb.config.xml.impl;

import fi.jab.esb.config.xml.JbossesbType;
import fi.jab.esb.config.xml.ProvidersType;
import fi.jab.esb.config.xml.ServicesType;
import fi.jab.esb.config.xml.XmlPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Jbossesb Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fi.jab.esb.config.xml.impl.JbossesbTypeImpl#getProviders <em>Providers</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.JbossesbTypeImpl#getServices <em>Services</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.JbossesbTypeImpl#getParameterReloadSecs <em>Parameter Reload Secs</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class JbossesbTypeImpl extends EObjectImpl implements JbossesbType
{
  /**
   * The cached value of the '{@link #getProviders() <em>Providers</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getProviders()
   * @generated
   * @ordered
   */
  protected ProvidersType providers;

  /**
   * The cached value of the '{@link #getServices() <em>Services</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getServices()
   * @generated
   * @ordered
   */
  protected ServicesType services;

  /**
   * The default value of the '{@link #getParameterReloadSecs() <em>Parameter Reload Secs</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParameterReloadSecs()
   * @generated
   * @ordered
   */
  protected static final Object PARAMETER_RELOAD_SECS_EDEFAULT = "180";

  /**
   * The cached value of the '{@link #getParameterReloadSecs() <em>Parameter Reload Secs</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParameterReloadSecs()
   * @generated
   * @ordered
   */
  protected Object parameterReloadSecs = PARAMETER_RELOAD_SECS_EDEFAULT;

  /**
   * This is true if the Parameter Reload Secs attribute has been set.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   * @ordered
   */
  protected boolean parameterReloadSecsESet;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected JbossesbTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XmlPackage.Literals.JBOSSESB_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ProvidersType getProviders()
  {
    return providers;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetProviders(ProvidersType newProviders, NotificationChain msgs)
  {
    ProvidersType oldProviders = providers;
    providers = newProviders;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XmlPackage.JBOSSESB_TYPE__PROVIDERS, oldProviders, newProviders);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setProviders(ProvidersType newProviders)
  {
    if (newProviders != providers)
    {
      NotificationChain msgs = null;
      if (providers != null)
        msgs = ((InternalEObject)providers).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XmlPackage.JBOSSESB_TYPE__PROVIDERS, null, msgs);
      if (newProviders != null)
        msgs = ((InternalEObject)newProviders).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XmlPackage.JBOSSESB_TYPE__PROVIDERS, null, msgs);
      msgs = basicSetProviders(newProviders, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.JBOSSESB_TYPE__PROVIDERS, newProviders, newProviders));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ServicesType getServices()
  {
    return services;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetServices(ServicesType newServices, NotificationChain msgs)
  {
    ServicesType oldServices = services;
    services = newServices;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XmlPackage.JBOSSESB_TYPE__SERVICES, oldServices, newServices);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setServices(ServicesType newServices)
  {
    if (newServices != services)
    {
      NotificationChain msgs = null;
      if (services != null)
        msgs = ((InternalEObject)services).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XmlPackage.JBOSSESB_TYPE__SERVICES, null, msgs);
      if (newServices != null)
        msgs = ((InternalEObject)newServices).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XmlPackage.JBOSSESB_TYPE__SERVICES, null, msgs);
      msgs = basicSetServices(newServices, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.JBOSSESB_TYPE__SERVICES, newServices, newServices));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Object getParameterReloadSecs()
  {
    return parameterReloadSecs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParameterReloadSecs(Object newParameterReloadSecs)
  {
    Object oldParameterReloadSecs = parameterReloadSecs;
    parameterReloadSecs = newParameterReloadSecs;
    boolean oldParameterReloadSecsESet = parameterReloadSecsESet;
    parameterReloadSecsESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.JBOSSESB_TYPE__PARAMETER_RELOAD_SECS, oldParameterReloadSecs, parameterReloadSecs, !oldParameterReloadSecsESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void unsetParameterReloadSecs()
  {
    Object oldParameterReloadSecs = parameterReloadSecs;
    boolean oldParameterReloadSecsESet = parameterReloadSecsESet;
    parameterReloadSecs = PARAMETER_RELOAD_SECS_EDEFAULT;
    parameterReloadSecsESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, XmlPackage.JBOSSESB_TYPE__PARAMETER_RELOAD_SECS, oldParameterReloadSecs, PARAMETER_RELOAD_SECS_EDEFAULT, oldParameterReloadSecsESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isSetParameterReloadSecs()
  {
    return parameterReloadSecsESet;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case XmlPackage.JBOSSESB_TYPE__PROVIDERS:
        return basicSetProviders(null, msgs);
      case XmlPackage.JBOSSESB_TYPE__SERVICES:
        return basicSetServices(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XmlPackage.JBOSSESB_TYPE__PROVIDERS:
        return getProviders();
      case XmlPackage.JBOSSESB_TYPE__SERVICES:
        return getServices();
      case XmlPackage.JBOSSESB_TYPE__PARAMETER_RELOAD_SECS:
        return getParameterReloadSecs();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XmlPackage.JBOSSESB_TYPE__PROVIDERS:
        setProviders((ProvidersType)newValue);
        return;
      case XmlPackage.JBOSSESB_TYPE__SERVICES:
        setServices((ServicesType)newValue);
        return;
      case XmlPackage.JBOSSESB_TYPE__PARAMETER_RELOAD_SECS:
        setParameterReloadSecs(newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.JBOSSESB_TYPE__PROVIDERS:
        setProviders((ProvidersType)null);
        return;
      case XmlPackage.JBOSSESB_TYPE__SERVICES:
        setServices((ServicesType)null);
        return;
      case XmlPackage.JBOSSESB_TYPE__PARAMETER_RELOAD_SECS:
        unsetParameterReloadSecs();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.JBOSSESB_TYPE__PROVIDERS:
        return providers != null;
      case XmlPackage.JBOSSESB_TYPE__SERVICES:
        return services != null;
      case XmlPackage.JBOSSESB_TYPE__PARAMETER_RELOAD_SECS:
        return isSetParameterReloadSecs();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (parameterReloadSecs: ");
    if (parameterReloadSecsESet) result.append(parameterReloadSecs); else result.append("<unset>");
    result.append(')');
    return result.toString();
  }

} //JbossesbTypeImpl
